package com.lagou.edu.controller;

import com.lagou.edu.pojo.User;
import com.lagou.edu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/findById/{id}")
    public User findById(@PathVariable(name = "id") Integer id){
        return userService.findById(id);
    }

    @RequestMapping("/delete/{id}")
    public void deleteById(@PathVariable(name = "id") Integer id){
         userService.deleteById(id);
    }
    @RequestMapping("/add")
    public void add(@RequestBody User user){
        userService.add(user);
    }
    @RequestMapping("/update")
    public void update(@RequestBody User user){
        userService.update(user);
    }
}
